<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->systemName;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/style.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/cn.js"></script>

</head>

<body>
	<div id="main">
		<div id="navigation">当前位置：<a href="<?php echo $this->projectUrl(array('action'=>'index'));?>">分支协议列表</a> &gt; <a href="<?php echo $this->projectUrl(array('action'=>'child-event','childVersion'=>$this->vars['childVersion']));?>">[<?php echo $this->vars['childVersion'];?>]事件列表</a> &gt;<span id="focus">添加事件</span></div>
		<div id="body">
			<div id="edit">
				<form id="editForm" name="editForm" method="post" action="">
					<table class="table">
						<tr>
							<td colspan="2">*为必填项</td>
						</tr>
						<tr>
							<td width="20%">分支协议版本号：</td>
							<td>
								<?php echo $this->vars['childVersion'];?>
								<input name="childVersion" type="hidden"id="childVersion" value="<?php echo $this->vars['childVersion'];?>" />
							</td>
						</tr>
						<tr>
							<td width="20%">事件Id：</td>
							<td>
								<input name="eventId" type="text" class="validate[callback[checkEventId,1]] input" id="eventId" value="" size="30" style="width:300px;" />* 
							</td>
						</tr>
						<tr>
							<td width="20%">事件别名：</td>
							<td>
								<input name="eventBagName" type="text" class="validate[callback[checkEventBagName,1]] input" id="eventBagName" value="" size="30" style="width:300px;" /> * 
							</td>
						</tr>
						<tr>
							<td width="20%">事件名称：</td>
							<td>
								<input name="eventName" type="text" class="validate[required] input" id="eventName" value="" size="30" style="width:300px;" />* 
							</td>
						</tr>
						<tr>
							<td width="20%">事件实现方式：</td>
							<td>	
								<input name="eventComplyMode" type="radio" class="type" value="0"  /> SDK
								<input name="eventComplyMode" type="radio" class="type" value="1" checked="checked"/> APP
							</td>
						</tr>
						<tr>
							<td width="20%">事件上传方式：</td>
							<td>	
								<input name="eventUploadMode" type="radio" class="type" value="0" checked="checked" /> 启动
								<input name="eventUploadMode" type="radio" class="type" value="1" /> 立即
								<input name="eventUploadMode" type="radio" class="type" value="2" /> 定时
								<input name="eventUploadMode" type="radio" class="type" value="3" /> WIFI连接
							</td>
						</tr>
						<tr>
							<td width="20%">事件生成时机：</td>
							<td>
								<input name="eventPoint" type="text" class="input" id="eventPoint" value="" size="30" style="width:300px;" /> 注：供埋点人员参考。
							</td>
						</tr>
						<tr>
							<td width="20%">备注：</td>
							<td><textarea name="note" cols="30" rows="5" class="input" id="note" style="width:300px;"></textarea></td>
						</tr>
						<tr>
							<td width="20%">&nbsp;</td>
							<td><input type="submit" name="button" id="button" value="提交" class="button"/></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>

<script language="javascript">
function checkEventId(account)
{
    var url = '<?php echo $this->projectUrl(array('action'=>'get-child-pact-event-id-is-exists-by-json','childVersion'=>$this->vars['childVersion'], 'account'=>'{account}'), NULL, false);?>'+'?rand/' + Math.random();
	url = url.replace('{account}', account);
	checkResult = {'isRight':true, 'message':''};
	
	if ($.trim($("#eventId").val()) == '') {
		return checkResult = {'isRight':false, 'message':'事件 Id。'};
	}
	if (account != '') {
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			async: false,
			success: function(data){
				if (data == 1) {
					checkResult = {'isRight':false, 'message':'* 此协议版本号下的事件Id已存在，请换一个。'};
				}
			} 
		}); 
	}
	return checkResult;
}

function checkEventBagName(account)
{
    var url = '<?php echo $this->projectUrl(array('action'=>'get-child-pact-event-bag-name-is-exists-by-json','childVersion'=>$this->vars['childVersion'], 'account'=>'{account}'), NULL, false);?>'+'?rand/' + Math.random();
	url = url.replace('{account}', account);
	checkResult = {'isRight':true, 'message':''};
	
	if ($.trim($("#eventBagName").val()) == '') {
		return checkResult = {'isRight':false, 'message':'事件别名。'};
	}
	if (account != '') {
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			async: false,
			success: function(data){
				if (data == 1) {
					checkResult = {'isRight':false, 'message':'* 此协议版本号下的事件别名已存在，请换一个。'};
				}
			} 
		}); 
	}
	return checkResult;
}



$("#editForm").submit(function(){
	return true;
});
</script>
</body>
</html>